{% load nm %}
<table class="proctable tablesorter">
    <thead>
        <tr>
            <th>Applicant</th>
            <th>From</th>
            <th>To</th>
            <th>Applying for</th>
            <th>Progress</th>
            <th>AM</th>
            <th>Advocate(s)</th>
    </thead>
    <tbody>
        {% for p in processes %}
        <tr>
        <td><a href="{{ p.get_absolute_url }}" title="{{p.person.fullname}}">{{p.person.uid|default:p.person.fullname}}</a></td>
            <td val="{{p.started|date:'Y-m-d'}}">{{p.started.date}}</td>
            <td val="{{p.started|date:'Y-m-d'}}">{{p.ended.date}}</td>
            <td>{{p.applying_for|desc_status}} ({{p.is_active|yesno:"in progress,done"}})</td>
            <td>
                {% if p.is_active %}
                <a href="{% url 'public_progress' progress=p.progress %}">{{p.progress|desc_progress}}</a>
                {% else %}
                {{p.progress|desc_progress}}
                {% endif %}
            </td>
            <td>
                {% if p.manager %}
                <a href="{{ p.manager.get_absolute_url }}" title="{{p.manager.person.fullname}}">{{p.manager.person.uid|default:"None"}}</a>
                {% else %}
                None
                {% endif %}
            </td>
            <td>
                {% for a in p.advocates.all %}
                <a href="{{ a.get_absolute_url }}" title="{{a.fullname}}">{{a.uid}}</a>{% if not forloop.last %},{% endif %}
                {% endfor %}
            </td>
        </tr>
        {% endfor %}
    </tbody>
</table>

